package com.happywynne.elasticsearchtravel.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Wynne.Lu
 * @date 2021/1/14 下午10:15
 * @desc
 */
@Configuration
public class ElasticsearchClientConfig {

    private static final HttpHost[] ES_INSTANCE_ARR;

    static {
        // 此处添加es实例
        ES_INSTANCE_ARR = new HttpHost[]{
                new HttpHost("124.70.48.18", 9200, "http")
//                new HttpHost("192.168.0.174", 9200, "http")
        };
    }

    @Bean
    public RestHighLevelClient esClient() {
        return new RestHighLevelClient(
                RestClient.builder(ES_INSTANCE_ARR)
        );
    }

}
